package net.qhzw.vip.qiyu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.qhzw.vip.qiyu.dto.DispatchHistoryDto;
import net.qhzw.vip.qiyu.dto.MaintRptDto;
import net.qhzw.vip.qiyu.dto.MaintUserDto;
import net.qhzw.vip.qiyu.dto.MaintUserFraction;
import net.qhzw.vip.qiyu.entity.DtsUser;
import net.qhzw.vip.qiyu.entity.MaintRpt;
import net.qhzw.vip.qiyu.entity.SysCommunity;
import net.qhzw.vip.qiyu.param.MaintQuery;
import net.qhzw.vip.qiyu.util.PageAdapter;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

public interface MaintRptMapper extends BaseMapper<MaintRpt> {

    /***
     * 查看用户报案信息
     * @param pageAdapter
     * @param userId
     * @param maintRealName
     * @param maintMobile
     * @return
     */
    List<MaintRptDto> listUserReport(@Param("pageAdapter") PageAdapter pageAdapter,
                                     @Param("userId") Long userId,
                                     @Param("maintRealName") String maintRealName,
                                     @Param("maintMobile") String maintMobile);


    /***
     * 查看用户报案count
     * @param userId
     * @param maintRealName
     * @param maintMobile
     * @return
     */
    Long countUserReport(@Param("userId") Long userId,
                         @Param("maintRealName") String maintRealName,
                         @Param("maintMobile") String maintMobile);

    /***
     * 查看维修师傅信息
     * @param id
     * @return
     */
    MaintUserDto findMaintUserInfo(Long id);

    /**
     * 查询维修人员评分
     *
     * @param maintUserId
     * @return
     */
    MaintUserFraction countOrder(Long maintUserId);

    /**
     * 查看派单历史
     *
     * @param id
     * @return
     */
    List<DispatchHistoryDto> findDispatchHistory(Long id);


    /**
     * 查看用户报案信息列表
     *
     * @param pageAdapter
     * @param query
     * @return
     */
    List<MaintRptDto> findMaintenanceList(@Param("pageAdapter") PageAdapter pageAdapter,
                                          @Param("query") MaintQuery query);


    /***
     * 查看用户报案信息列表total
     * @param query
     * @return
     */
    Long findMaintenanceCount(@Param("query") MaintQuery query);


    /***
     *  查询维修站点
     * @param businessType
     * @param keywords
     * @return
     */
    List<SysCommunity> findCommunityList(@Param("businessType") Byte businessType,
                                         @Param("keywords") String keywords,
                                         @Param("page") PageAdapter page);

    Long findNearbyCommunityCount(String keywords);

    /**
     * 根据站点查询维修用户
     *
     * @param id
     * @return
     */
    List<DtsUser> getDtsUser(@Param("communityId") Long communityId,
                             @Param("maintRptId") Long maintRptId);


    void updateRepairUser(Long id);

    SysCommunity findByDtsUserId(Long userId);


    DtsUser maintFindDtsUserByUserId(Long maintUserId);


    int reportCheckd(Long userId);


    MaintRpt selectUrgentDispatchNotice(@Param("id") Long id, @Param("created") String created);


    List<MaintRptDto> selectRepairUserinfo();
}